package com.fr.report.adhoc;

import com.fr.base.core.json.JSONObject;
import com.fr.data.util.function.AverageFunction;
import com.fr.data.util.function.CountFunction;
import com.fr.data.util.function.DataFunction;
import com.fr.data.util.function.MaxFunction;
import com.fr.data.util.function.MinFunction;
import com.fr.data.util.function.SumFunction;
import com.fr.report.cellElement.Formula;
import java.util.HashMap;
import java.util.Map;

public class ADHOCSummaryColumn extends SimpleADHOCColumn
{
  private String weeklySummaryColumn;
  private String monthlySummaryColumn;
  private String yearlySummaryColumn;
  private String function;
  private Map funMap = new HashMap();

  public void initMap()
  {
    if (this.funMap.size() < 1)
    {
      this.funMap.put("sum", new SumFunction());
      this.funMap.put("ave", new AverageFunction());
      this.funMap.put("max", new MaxFunction());
      this.funMap.put("min", new MinFunction());
      this.funMap.put("count", new CountFunction());
      this.funMap.put("weeksummary", new SumFunction());
      this.funMap.put("monthsummary", new SumFunction());
      this.funMap.put("yearsummary", new SumFunction());
    }
  }

  public Formula createWMYFormula()
  {
    String str = null;
    if (getFunctionString().equals("weeksummary"))
      break label44:
    if (getFunctionString().equals("monthsummary"))
      break label44:
    if (getFunctionString().equals("yearsummary"));
    label44: Formula localFormula = new Formula(str);
    return localFormula;
  }

  public DataFunction getFunction()
  {
    if (this.funMap.size() < 1)
      initMap();
    return ((DataFunction)this.funMap.get(getFunctionString()));
  }

  public String getWeeklySummaryColumn()
  {
    return this.weeklySummaryColumn;
  }

  public void setWeeklySummaryColumn(String paramString)
  {
    this.weeklySummaryColumn = paramString;
  }

  public String getMonthlySummaryColumn()
  {
    return this.monthlySummaryColumn;
  }

  public void setMonthlySummaryColumn(String paramString)
  {
    this.monthlySummaryColumn = paramString;
  }

  public String getYearlySummaryColumn()
  {
    return this.yearlySummaryColumn;
  }

  public void setYearlySummaryColumn(String paramString)
  {
    this.yearlySummaryColumn = paramString;
  }

  public String getFunctionString()
  {
    return this.function;
  }

  public void setFunction(String paramString)
  {
    this.function = paramString;
  }

  public JSONObject createJSON()
    throws Exception
  {
    return null;
  }

  public void parseJSON(JSONObject paramJSONObject)
    throws Exception
  {
    super.parseJSON(paramJSONObject);
    setFunction(paramJSONObject.getString("funname"));
    if (paramJSONObject.has("weeksummary"))
      setWeeklySummaryColumn(paramJSONObject.getString("weeksummary"));
    if (paramJSONObject.has("monthsummary"))
      setMonthlySummaryColumn(paramJSONObject.getString("monthsummary"));
    if (paramJSONObject.has("yearsummary"))
      setYearlySummaryColumn(paramJSONObject.getString("yearsummary"));
  }
}